{% extends 'layout.njk' %}
{% block content %}

    <div>
        username:
        <input class='username'/>
        <button class='btn'>下一步</button>
    </div>
{% endblock %}

{% block script %}

    <script>
        let ele = document.querySelector('.username')
        ele.onblur = function () {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/checkUsername' ,
                data: {name : ele.value},
                success: (result) => {
                    if (result.status === 'failed') {
                        alert('用户名已经存在')
                    }
                }
            })
        }
        btnEle.onclick =()=>{
        let data = {step:1},
        location.href = '/passwordRegist'
    </script>
{% endblock %}